<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/carousel.css">
</head>

<body>
    <div class="carousel">
        <div class="left" id="toLeft">
            《
        </div>
        <div class="itmes" id="itemsList">
            <img src="./imgs/1.png" alt="">
            <img src="./imgs/2.png" alt="">
            <img src="./imgs/3.png" alt="">
            <img src="./imgs/4.png" alt="">
            <img src="./imgs/5.png" alt="">
            <img src="./imgs/6.png" alt="">
            <img src="./imgs/7.png" alt="">
            <img src="./imgs/8.png" alt="">
            <img src="./imgs/9.png" alt="">
            <img src="./imgs/10.png" alt="">
        </div>
        <div class="right" id="toRight">
            》
        </div>
    </div>

    <script>
        const toLeft = document.getElementById('toLeft');
        const toRight = document.getElementById('toRight');
        const itemsList = document.getElementById('itemsList');

        toLeft.onclick = function () {
            const left = itemsList.offsetLeft;
            if (left <= -600) {
                itemsList.style.marginLeft = -700 + 'px';
            } else {
                itemsList.style.marginLeft = left - 300 + 'px';
            }
        }
        toRight.onclick = function () {
            const left = itemsList.offsetLeft;
            if (left >= -100) {
                itemsList.style.marginLeft = 0 + 'px'
            } else {
                itemsList.style.marginLeft = left + 300 + 'px';
            }
        }



    </script>

</body>

</html>